import Vue from "vue";
import Router from "vue-router";
import Layout from "../views/layout/Layout";
import dataCenter from "./dataCenter";
import commodity from "./commodity";
import tools from "./tools";
import order from "./order";
// import statistics from "./statistics";
import set from "./set";
import upgradeMakeMoney from "./upgradeMakeMoney";
import privilegeConfig from "./privilegeConfig";
import vipConfig from "./vipConfig";
import recommendReward from "./recommendReward";
import teamRebate from "./teamRebate";
import sysUser from "./sysUser";
import user from "./user";
import advice from "./advice";
import ad from "./ad";
import box from "./box";
import activity from "./activity";
import bixuanManage from "./bixuanManage";
import reconciliation from "./reconciliation";
// import balance from './balance'
import finance from './finance'
// import goddess from './goddess'
import message from './message'
import sysSetting from './sysSetting'
import appConfig from './appConfig'
import mobileMessage from './mobileMessage'
// import commercialCollege from './commercialCollege'
import bihuasuan from './bihuasuan'
import bizhibo from './bizhibo'
import goodsMiddleStage from './goodsMiddleStage'
import electronicInvoice from './electronicInvoice'

import biquan from './biquan'
import merManageSys from './merManageSys'
import boxTrans from './box_translation'
import redPharmacy from './redPharmacy'
const _import = require('./_import_' + process.env.NODE_ENV);
Vue.use(Router);

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
 **/
export const constantRouterMap = [{
    path: "/redirect/:path*",
    component: () => import("@/views/redirect/index")
  },
  {
    path: "/login",
    component: _import("login/index"),
    hidden: true
  },
  {
    path: "/authredirect",
    component: _import("login/authredirect"),
    hidden: true
  },
  {
    path: "/404",
    component: _import("errorPage/404"),
    hidden: true
  },
  {
    path: "/401",
    component: _import("errorPage/401"),
    hidden: true
  }
  /*{
    path: '',
    component: Layout,
    redirect: '/dataCenter/all',
    meta: {roles: [1]}
    /*children: [{
      path: 'dashboard',
        component: _import('dashboard/index'),
        name: 'dashboard',
        meta: {title: '后台首页', icon: 'dashboard', noCache: true}

         : '/commodity/manage'
    }]
    }*/
];
export default new Router({
  mode: "history",
  base: process.env.BASE_URL,
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
});

export let asyncRouterMap = [{
    path: "",
    component: Layout,
    redirect: "/dataCenter/all",
    meta: {}
  },
  //merchant
  //merManageSys,
  dataCenter,
  commodity,
  activity,
  bixuanManage,
  // tools,
  boxTrans,
  // box,
  biquan,
  bihuasuan,
  bizhibo,
  redPharmacy,
  order,
  ad,
  appConfig,
  sysSetting,
  sysUser,
  // reconciliation,
  // statistics,
  // commercialCollege,
  set,
  // upgradeMakeMoney,
  // privilegeConfig,
  // vipConfig,
  // recommendReward,
  // teamRebate,
  // user,
  // advice,
  // message,
  // balance,
  finance,
  // mobileMessage,
  // electronicInvoice,
  // goddess,
  {
    path: "*",
    redirect: "/404",
    hidden: true
  },
];
//uat放开商品中台
if (process.env.ENV_CONFIG == "uat") {
  asyncRouterMap.splice(3, 0, goodsMiddleStage)
}
